<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查看进程</title>
    <link rel="stylesheet" href="${ctx}/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="${ctx}/assets/css/app.css">
    <link rel="stylesheet" href="${ctx}/assets/css/layer.css">
    <link rel="stylesheet" href="${ctx}/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="${ctx}/assets/css/taskAlgorithmSettingByBatchTasks.css">
    <link rel="stylesheet" type="text/css" href="${ctx}/assets/css/xcConfirm.css"/>
</head>
<body>
<div class="form-main">
    <input type="hidden" id="task_number">
    <div class="form-header">
        <h3 id="y-title">查看进程</h3>
    </div>
    <hr>
    <div class="content" id="param_form" style="width:300px">
 		<input id="hostIP" type="hidden" />
    </div>
    <hr>
    
    <!-- <div class="action mr20" style="float: right;" id="closeIframe">
        <ul class="actions-btn"><li class="green">取消</li></ul>
    </div>
    <div class="action mr20" style="float: right;" id="saveSetting">
        <ul class="actions-btn"><li class="green">确定</li></ul>
    </div> -->
</div>
<script src="${ctx}/assets/js/jQuery/jquery-1.9.1.js"></script>
<script src="${ctx}/assets/js/jQuery/jquery.min.js"></script>
<script src="${ctx}/assets/js/common/common.fun.js"></script>
<script src="${ctx}/assets/js/common/config.js"></script>
<script src="${ctx}/assets/js/common/bootstrap.js"></script>
<script src="${ctx}/assets/js/common/xcConfirm.js"></script>
<script src="${ctx}/assets/js/layer/layer.js"></script>
<script>
$(function () {
	var hostIP = GetQueryString("hostIP");
	$.ajax({
        type:"GET",
        url:constUrl+"ws/remote/process/check",
        dataType:"json",
        data: {
            IP:hostIP
        },
        success:function(data){
        	console.log(data);
        	if(data.desc=="SUCCESS"){
        	//	$("#param_form").html(data.data);
        	var rows = data.data.split("#");
        	if(rows.length>1){
        		/* var title = "<p></p>";
        		$("#param_form").(); */
        	}else{
        		$("#param_form").html(data.data);
        		return;
        	}
        	for(var i=0;i<rows.length;i++){
        		if(rows[i]==""|| rows[i]==null){
        			break;
        		}
        				var procName = rows[i].split(",")[0];
        				var execName = procName.split(":")[1];
        				var dom = "<div style='float:left'><p style='float:left'>进程："+procName+"</p><input type='checkbox' style='float:right' name='kill' value='"+execName+"'/></div><br>"
        					
        				$("#param_form").append(dom);
        				}
        	$("#param_form").append("<button class='btn btn-info'style='float:right;margin-top:40px' id='killBtn'onclick='killProc()' >终止勾选进程</button>");
        	}else{
        		alert("ERROR");
        	}
        	
        },error:function(data){
        	alert("URL ERROR");
        }
    });
});

function killProc(){
	var procs = $('input[type="checkbox"][name="kill"]:checked').map(function () {
        return $(this).val();
    }).get().join(",");
	//console.log(procs);
	var hostIP = GetQueryString("hostIP");
//	alert(hostIP);
	 $.ajax({
        type:"GET",
        url:constUrl+"ws/remote/proc/kill",
        dataType:"json",
        data: {
            IP:hostIP,
            procs:procs
        },
        success:function(data){
        	layer.msg('进程终止成功', {
                time: 3000 //1s后自动关闭
        			}); 
        	formClose();
        }});
	}


function formClose(){
	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    //layer.msg(index);
    parent.layer.close(index); //再执行关闭 
}
</script>

</body>
</html>
